package com.xishu.dao.jpa;

import com.xishu.entity.customer.CustomerTicket;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface CustomerTicketDao extends JpaRepository<CustomerTicket, Long>, JpaSpecificationExecutor<CustomerTicket> {
    /**
     * 给没有使用过的，并且没有过期的会员优惠券过期
     *
     * @param endExpiredTime
     */
    @Modifying
    @Transactional
    @Query("update customer_ticket set expired = true  where expiredTime<= :endExpiredTime and expired != true and used != true")
    public void expireTicket(Long endExpiredTime);
}
